//
//  HLIMInputViewProtocol.h
//  YueYue
//
//  Created by hulu001 on 2024/1/11.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "HLIMKitAction.h"
#import "HLIMKitInputMoreItem.h"

#ifndef HLIMInputViewProtocol_h
#define HLIMInputViewProtocol_h


@class HLIMKitInputMoreItem;
@protocol HLIMKitInputView;

typedef NS_ENUM(NSInteger,HLIMInputStatus)
{
    HLIMInputStatusText,
    HLIMInputStatusAudio,
    HLIMInputStatusEmoticon,
    HLIMInputStatusMore,
    HLIMInputStatusRealVoice,
    HLIMInputStatusNone,
};

typedef NS_ENUM(NSUInteger, HLAudioRecordStatus) {
    HLAudioRecordStatusBegin,
    HLAudioRecordStatusRecording,
    HLAudioRecordStatusCancelling,
    HLAudioRecordStatusEnd,
};

typedef NS_ENUM(NSUInteger, HLIMRealVoiceStatus) {
    HLIMRealVoiceStatusRecording,     ///< 录音中
    HLIMRealVoiceStatusTranslacting,  ///< 翻译中
    HLIMRealVoiceStatusTranslacted,   ///< 已经翻译完成
};

@protocol HLIMKitInputViewActionDelegate <NSObject>

- (void)onTextChanged:(id)sender;

- (void)onSendText:(NSString *)text
           atUsers:(NSArray *)atUsers;

- (void)onSelectChartlet:(NSString *)chartletId
                 catalog:(NSString *)catalogId;

- (void)onRecordTouchChanged:(CGPoint)point
                      inView:(UIView *)view
                       state:(UIGestureRecognizerState)state;


#pragma mark - 录音UI操作回调

/// 按下录音按钮 开始计时
- (void)recordBeginTouch;
/// 在录音按钮上松开手指 —— 正常结束录音
- (void)recordFinishInButton;
/// 在录音按钮外面松开手指 —— 取消
- (void)recordFinishOutButton;
/// 手指滑动到录音按钮手势响应区域外 —— 提示取消录音 【录音及计时正常进行】
- (void)recordDragToOut;
/// 手指又返回录音按钮手势响应区域 —— 恢复正常录音 显示计时
- (void)recordDragBackToButton;


- (void)onTapMoreBtn:(id)sender;

- (void)onTapEmoticonBtn:(id)sender;

- (void)onTapVoiceBtn:(id)sender;

- (void)onTapMoreItem:(HLIMKitInputMoreItem *)moreItem;

- (void)onTapGiftButton:(id)sender;

- (void)onTapVideoCall;

- (void)onTapAudioCall;
 
- (void)onTapPhotoButton;

- (void)onTapEmojiButton:(BOOL)isSearch;

- (void)onTapEmojiButtonWithUrl:(NSString *)urlString image:(UIImage *)image;

- (void)onTapTopicButton:(UIButton *)btn;

- (BOOL)onStartRealVoice;
/// 实时语音结束
- (void)onFinishRealVoice:(void(^)(BOOL re))handler;
- (NSArray *)languagesForRealVoice;
- (void)onSelectedLanguage:(NSInteger)index;

@end

@protocol HLIMKitInputViewDelegate <NSObject>
@optional
- (void)didChangeInputHeight:(CGFloat)inputHeight;
/// 监听到用户输入@触发
/// 调用 IMKitInputView 的 insertText: 插入选中艾特后的内容到输入框
- (void)beginAt:(id<HLIMKitInputView>)inputView;

@end

@protocol HLIMKitInputViewConfig <NSObject>

@optional
/// 更多的面板
- (NSArray<HLIMKitInputMoreItem *> *)moreItems;

/// 更多面板中每一选项的size
- (CGSize)moreItemSize;

/// 更多面板内容四边内距
- (UIEdgeInsets)moreContainerContentInsets;

/// 最大字符输入数量
- (NSInteger)maxInputCharCount;

- (BOOL)shouldAt;

@end

@protocol HLIMKitInputView <NSObject>

- (UIView *)view;

- (UIView *)toolBar;

- (BOOL)keyboardIsVisiable;

@property (assign, nonatomic) HLIMInputStatus status;

@property (assign, nonatomic) id<HLIMKitInputViewDelegate> delegate;

@property (assign, nonatomic) id<HLIMKitInputViewActionDelegate> actionDelegate;

@property (strong, nonatomic) id<HLIMKitInputViewConfig> config;

@property (assign, nonatomic) BOOL recording;

@property (assign, nonatomic) HLAudioRecordStatus recordStatus;
@property (assign, nonatomic) NSTimeInterval recordTime;

- (void)refreshStatus:(HLIMInputStatus)status;

- (void)closeKeyboard;

- (void)forbidSpeaking:(BOOL)isForbidSpeaking;

- (BOOL)endEditing:(BOOL)force;

- (void)beginEditing;

- (void)insertText:(NSString *)text;

- (void)quoteMessage:(id)message;
- (void)clearQuote;

/// 外部插入艾特信息
/// @param nick @的用户昵称
/// @param uid @ 的用户ID
/// @param hasAtChar 是否插入@字符 。NO：只插入Nick，YES：“@张三”
- (void)insertAtUser:(NSString *)nick uid:(NSString *)uid hasAtChar:(BOOL)hasAtChar;

/// 扩展自定义
- (void)registerContainer:(UIView *)containerView key:(NSString *)key;
- (void)checkRealVoiceContainer;
- (void)changeVoiceValue:(CGFloat)value;
- (void)completeRealVoiceTranslaction;

@end


#endif /* HLIMInputViewProtocol_h */
